import { ApiProperty } from '@midwayjs/swagger';
import { Rule, RuleType } from '@midwayjs/validate';
import { Column, Entity, PrimaryColumn } from 'typeorm';
export enum CuState {
  enable = 'enable',
  disable = 'disable',
}
@Entity({
  name: 'shcustomer',
  synchronize: false,
})
export class ShCustomer {
  @ApiProperty({ example: 'sh000001' })
  @Rule(RuleType.string().min(0).required())
  @PrimaryColumn()
  cuId: string;
  @ApiProperty({ example: '张三' })
  @Rule(RuleType.string().allow(null).min(0).required())
  @Column({ nullable: true })
  cuNikeName: string;
  @ApiProperty({ example: '17560676030' })
  @Rule(RuleType.string().allow(null).min(11).max(11).required())
  @Column({ nullable: true })
  cuPhone: string;
  @ApiProperty({ example: 'zhangsan001' })
  @Rule(RuleType.string().allow(null).min(0).required())
  @Column()
  cuAccountNum: string;
  @ApiProperty({ example: '123456' })
  @Rule(RuleType.string().allow(null).min(6).max(15).required())
  @Column()
  cuPassword: string;
  @ApiProperty({ example: CuState.enable })
  @Rule(
    RuleType.string()
      .valid(...Object.values(CuState))
      .required()
  )
  @Column({
    type: 'enum',
    enum: CuState,
    default: CuState.enable,
  })
  cuState: CuState;
}
export class ShCustomerInsertDto {
  @ApiProperty({ example: '张三' })
  @Rule(RuleType.string().allow(null).min(0).required())
  cuNikeName: string;
  @ApiProperty({ example: '17560676030' })
  @Rule(RuleType.string().allow(null).min(11).max(11).required())
  cuPhone: string;
  @ApiProperty({ example: 'zhangsan001' })
  @Rule(RuleType.string().allow(null).min(0).required())
  cuAccountNum: string;
  @ApiProperty({ example: '123456' })
  @Rule(RuleType.string().allow(null).min(6).max(15).required())
  cuPassword: string;
  @ApiProperty({ example: CuState.enable })
  @Rule(
    RuleType.string()
      .valid(...Object.values(CuState))
      .required()
  )
  cuState: CuState;
}
